<?php

namespace app\common\model;

use think\Model;

class GoodsRebate extends Model
{
    // 表名
    protected $name = 'goods_rebate';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'superior_type_text',
        'agent_type_text',
	    'area_type_text'
    ];
    

    
    public function getSuperiorTypeList()
    {
        //1按比例,2固定金额
        return ['1' => __('按比例'),'2' => __('固定金额')];
    }     

    public function getAgentTypeList()
    {
        return ['1' => __('按比例'),'2' => __('固定金额')];
    }     


    public function getSuperiorTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['superior_type'];
        $list = $this->getSuperiorTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }
	
	public function getAreaTypeList()
	{
		return ['1' => __('按比例'),'2' => __('固定金额')];
	}
	
	
	public function getAreaTypeTextAttr($value, $data)
	{
		$value = $value ? $value : $data['area_type'];
		$list = $this->getSuperiorTypeList();
		return isset($list[$value]) ? $list[$value] : '';
	}

    public function getAgentTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['agent_type'];
        $list = $this->getAgentTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
